package com.neusoft.SPNursingHome.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neusoft.SPNursingHome.po.CheckOutRecord;
import com.neusoft.SPNursingHome.po.ResponseBean;
import com.neusoft.SPNursingHome.service.CheckOutRecordService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/checkout")
public class CheckOutRecordController {
    @Resource private CheckOutRecordService checkOutRecordService;

    @PostMapping("/list")
    public ResponseBean<IPage<CheckOutRecord>> list(
            @RequestParam(defaultValue = "1") long pageNum,
            @RequestParam(defaultValue = "10") long pageSize,
            @RequestBody Map<String, Object> query) {
        return checkOutRecordService.listRequests(pageNum, pageSize, query);
    }

    @PostMapping("/apply")
    public ResponseBean<Void> apply(@RequestBody CheckOutRecord request) {
        return checkOutRecordService.applyForCheckOut(request);
    }

    @PutMapping("/audit")
    public ResponseBean<Void> audit(
            @RequestBody CheckOutRecord auditInfo) {
        return checkOutRecordService.auditRequest(auditInfo);
    }
}
